<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/18
 * Time: 15:14
 */

namespace App\Http\Controllers\MiniProgram;


use App\Http\Logics\MiniProgram\RoleLogic;
use App\Http\Traits\RoleTrait;
use App\Http\Controllers\BaseController;
class RoleController extends BaseController
{
    use RoleTrait;
    /**
     * @SWG\Post(
     *     path="/role/setUserCity",
     *     tags={"Role"},
     *     description="给用户分配一间城市管理员角色",
     *     operationId="setUserCityRole",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="role_id",
     *         in="query",
     *         description="角色ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="city_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="form_id",
     *         in="query",
     *         description="系统消息通知需要的form_id",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function setUserCityRole()
    {
        $loginSession = $this->loginSession;
        $role_id  = $this->role_id;
        $city_id = $this->city_id;
        $form_id = $this->form_id;
        $data = [
            'form_id' => $form_id,
            'role_id' => $role_id,
            'city_id' => $city_id,
            'loginSession' => $loginSession,
        ];
        $response = RoleLogic::setUserCityRole($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/role/setUserCafe",
     *     tags={"Role"},
     *     description="给用户分配咖啡馆主角色",
     *     operationId="setUserCafeRole",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="role_id",
     *         in="query",
     *         description="角色ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="cafe_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="form_id",
     *         in="query",
     *         description="系统消息通知需要的form_id",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function setUserCafeRole()
    {
        $loginSession = $this->loginSession;
        $role_id  = $this->role_id;
        $cafe_id = $this->cafe_id;
        $form_id = $this->form_id;
        $data = [
            'form_id' => $form_id,
            'role_id' => $role_id,
            'cafe_id' => $cafe_id,
            'loginSession' => $loginSession,
        ];
        $response = RoleLogic::setUserCafeRole($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/role/setUserPartner",
     *     tags={"Role"},
     *     description="给用户分配咖啡馆角色",
     *     operationId="setUserPartnerRole",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_name",
     *         in="query",
     *         description="合作者名称",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_logo",
     *         in="query",
     *         description="合作者LOGO",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_summary",
     *         in="query",
     *         description="合作者简介",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_gzh_name",
     *         in="query",
     *         description="合作者公众号名称",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_mobile",
     *         in="query",
     *         description="合作者联系方式",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_since",
     *         in="query",
     *         description="合作者创建时间",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="role_id",
     *         in="query",
     *         description="角色ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="form_id",
     *         in="query",
     *         description="系统消息通知需要的form_id",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function setUserPartnerRole()
    {
        $loginSession = $this->loginSession;
        $name = $this->partner_name;
        $logo = $this->partner_logo;
        $summary = $this->partner_summary;
        $gzh_name = $this->partner_gzh_name;
        $mobile = $this->partner_mobile;
        $since = $this->partner_since;
        $role_id  = $this->role_id;
        $form_id = $this->form_id;
        $data = [
            'name' => $name,
            'logo' => $logo,
            'summary' => $summary,
            'gzh_name' => $gzh_name,
            'mobile' => $mobile,
            'since' => $since,
            'form_id' => $form_id,
            'role_id' => $role_id,
            'loginSession' => $loginSession
        ];
        $response = RoleLogic::setUserPartnerRole($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}